package avicit.bdp.dcs.utils.api.response;

import avicit.bdp.dcs.utils.api.enums.ResponseType;
import avicit.platform6.core.exception.BusinessException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ResponseAdapterUtil {

    private static final Logger LOG = LoggerFactory.getLogger(ResponseAdapterUtil.class);

    public static ResponseAdapter getResponseAdapter(String responseTypeStr) {
        ResponseType responseType = ResponseType.getResponseType(responseTypeStr);
        switch (responseType) {
            case JSON:
                return JsonAdapter.instance();
            case XML:
                return XmlAdapter.instance();
            default:
                String msg = String.format("不支持的返回数据格式%s", responseTypeStr);
                LOG.error(msg);
                throw new BusinessException(msg);
        }
    }

}
